package com.zmn.mcc.permit.client.policy.impl;

import com.zmn.mcc.permit.client.exception.NoPermitException;
import com.zmn.mcc.permit.client.model.InterceptDecisionBO;
import com.zmn.mcc.permit.client.policy.interfaces.NoPermissionPolicy;
import lombok.SneakyThrows;

import java.lang.reflect.Field;

/**
 * 无权限时不处理属性，不返回数据，直接抛出异常
 *
 * @author hankangshuai
 * @since 2020/06/18
 */
public class ThrowExceptionPolicyImpl implements NoPermissionPolicy {

    @SneakyThrows
    @Override
    public InterceptDecisionBO processNoPermission(Object noPermissionParamObj, Field noPermissionField, Object[] targetAllParams) {
        throw new NoPermitException(noPermissionField.getName());
    }
}
